"""
#  集合是无序的，所以不支持下标索引访问，元素是不重复的
# 定义集合
my_set = {"lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男"}
my_set_null = set()
print(f"集合my_set的内容为：{my_set}，类型为：{type(my_set)}")
print(f"集合my_set_null的内容为：{my_set_null}，类型为：{type(my_set_null)}")

# 添加新元素
my_set = {"lijianqi","liaogong","software",22,"男"}
my_set.add("73")
print(f"添加新元素后的新集合内容为：{my_set}")

# 移除元素
my_set = {"lijianqi","liaogong","software",22,"男"}
my_set.remove("liaogong")
print(f"移除元素后的新集合内容为：{my_set}")

# 随机取出一个元素
my_set = {"lijianqi","liaogong","software",22,"男"}
element = my_set.pop()
print(f"随机取出一个元素：{element}，取出元素后：{my_set}")

# 清空集合
my_set.clear()
print(f"集合被清空了，结果是：{my_set}")

# 取出2个集合的差集     语法：集合1.difference(集合2)，功能：取出集合1和集合2的差集（集合1有而集合2没有的）
set1 = {1,2,3}
set2 = {1,5,6}
set3 = set1.difference(set2)
print(f"集合1的内容为：{set1}，集合2的内容为：{set2}，差集为：{set3}")

# 消除2个集合的差集         语法：集合1.difference_update(集合2)，功能：在集合1内，删除和集合2相同的元素      结果：集合1被修改，集合2不变
set4 = {1,2,3}
set5 = {1,5,6}
set4.difference_update(set5)
print(f"消除差集后，集合1的内容为：{set4}，集合2的内容为：{set5}")

# 2个集合合并        语法：集合1.union(集合2)       功能：将集合1和集合2组合成新集合   结果：得到新集合，集合1集合2内容不变
set6 = {4,5,6}
set7 = {7,8,6}
set8 = set6.union(set7)
print(f"新集合的内容为：{set8}，集合1的内容为：{set6}，集合2的内容为：{set7}")

# 统计集合元素数量  len函数
my_set = {"lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男"}
num = len(my_set)
print(f"集合元素的数量为：{num}")

# 集合遍历，由于集合不支持下标索引，所以不能用while循环，可以用for循环
my_set = {"lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男","lijianqi","liaogong","software",22,"男"}
for element in my_set:
    print(f"集合my_set的元素有：{element}")
"""

# 综合练习
my_list = ['lijianqi','liaogong','software','73号','带专时期的Python资料','73号','带专时期的Python资料','73号','带专时期的Python资料']
my_set = set()
for element in my_list:
    my_set.add(element)
print(f"my_list列表的内容为：{my_list}")
print(f"my_set集合的内容为：{my_set}")